//
//  LeftSortsViewController.m
//  PianKe
//
//  Created by lanou3g on 15/10/13.
//  Copyright (c) 2015年 张文文. All rights reserved.
//

#import "LeftSortsViewController.h"
#import "AppDelegate.h"
#import "otherViewController.h"
#import "MyViewController.h"
#import "MusicViewController.h"
#import "FindViewController.h"
#import "MoreViewController.h"
#import "SearchViewController.h"
#import "LoginViewController.h"
#import "SetViewController.h"

@interface LeftSortsViewController ()<UITableViewDataSource, UITableViewDelegate>

@end

@implementation LeftSortsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //背景图片
    UIImageView *imageview = [[UIImageView alloc] initWithFrame:self.view.bounds];
    imageview.image = [UIImage imageNamed:@"01.png"];
    //imageview.backgroundColor = [UIColor blueColor];
    [self.view addSubview:imageview];
    
    //tableview
    UITableView *tableview = [[UITableView alloc] init];
    self.tableview = tableview;
    tableview.frame = self.view.bounds;
    tableview.dataSource = self;
    tableview.delegate  = self;
    tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:tableview];
    
//    //登录
//    UIImage *image = [UIImage imageNamed:@"20.png"];
//    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
//    imageView.frame = CGRectMake(10, 20, 50, 50);
//    [self.view addSubview:imageView];
//    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(80, 30, 100, 30)];
//    [button setTitle:@"登录/注册" forState:UIControlStateNormal];
//    //绑定事件
//    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
//    
//    [self.view addSubview:button];
//    
//    //功能栏
//      //下载
//    UIButton *button1 = [[UIButton alloc] initWithFrame:CGRectMake(20, 100, 30, 30)];
//    [button1 setImage:[UIImage imageNamed:@"18.png"] forState:UIControlStateNormal];
//    [self.view addSubview:button1];
//      //喜爱
//    UIButton *button2 = [[UIButton alloc] initWithFrame:CGRectMake(80, 100, 30, 30)];
//    [button2 setImage:[UIImage imageNamed:@"12.png"] forState:UIControlStateNormal];
//    [self.view addSubview:button2];
//    
//      //对话
//    UIButton *button3 = [[UIButton alloc] initWithFrame:CGRectMake(140, 100, 30, 30)];
//    [button3 setImage:[UIImage imageNamed:@"14.png"] forState:UIControlStateNormal];
//    [self.view addSubview:button3];
//      //评论
//    UIButton *button4 = [[UIButton alloc] initWithFrame:CGRectMake(200, 100, 30, 30)];
//    [button4 setImage:[UIImage imageNamed:@"17.png"] forState:UIControlStateNormal];
//    [self.view addSubview:button4];
//    
//    //搜索栏
//    UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(37, 146, 200, 30)];
//    searchBar.backgroundImage = [UIImage imageNamed:@"8"];
//    searchBar.placeholder = @"搜索";
//    [self.view addSubview:searchBar];
    
}
//#pragma mark - 实现button点击事件
//-(void)buttonAction:(UIButton *)sender{
//    LoginViewController *loginVC =[[LoginViewController alloc] init];
//    UINavigationController *loginNC = [[UINavigationController alloc]initWithRootViewController:loginVC];
//    [self presentViewController:loginNC animated:YES completion:nil];
////    [self.navigationController pushViewController:loginVC animated:YES];
//    
//}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 7;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *Identifier = @"Identifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Identifier];
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.font = [UIFont systemFontOfSize:20.0f];
    cell.backgroundColor = [UIColor clearColor];
    cell.textLabel.textColor = [UIColor whiteColor];
    
    if (indexPath.row == 0) {
        cell.textLabel.text = @"我的";
    } else if (indexPath.row == 1) {
        cell.textLabel.text = @"音乐馆";
    } else if (indexPath.row == 2) {
        cell.textLabel.text = @"发现";
    } else if (indexPath.row == 3) {
        cell.textLabel.text = @"更多";
    } else if (indexPath.row == 4) {
        cell.textLabel.text = @"搜索";
    } else if (indexPath.row == 5) {
        cell.textLabel.text = @"登录";
    } else if (indexPath.row == 6) {
        cell.textLabel.text = @"设置";
    }
    return cell;
}

//cell点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    if(indexPath.row == 0){
        MyViewController *myVC = [[MyViewController alloc] init];
        [tempAppDelegate.LeftSlideVC closeLeftView];//关闭左侧抽屉
        [tempAppDelegate.mainNavigationController pushViewController:myVC animated:NO];
    } else if (indexPath.row == 1){
        MusicViewController *musicVC = [[MusicViewController alloc] init];
        [tempAppDelegate.LeftSlideVC closeLeftView];//关闭左侧抽屉
        [tempAppDelegate.mainNavigationController pushViewController:musicVC animated:NO];
    } else if (indexPath.row == 2){
        FindViewController *findVC = [[FindViewController alloc] init];
        [tempAppDelegate.LeftSlideVC closeLeftView];//关闭左侧抽屉
        [tempAppDelegate.mainNavigationController pushViewController:findVC animated:NO];
    } else if (indexPath.row == 3){
        MoreViewController *moreVC = [[MoreViewController alloc] init];
        [tempAppDelegate.LeftSlideVC closeLeftView];//关闭左侧抽屉
        [tempAppDelegate.mainNavigationController pushViewController:moreVC animated:NO];
    } else if (indexPath.row == 4){
        SearchViewController *searchVC = [[SearchViewController alloc] init];
        [tempAppDelegate.LeftSlideVC closeLeftView];//关闭左侧抽屉
        [tempAppDelegate.mainNavigationController pushViewController:searchVC animated:NO];
    } else if (indexPath.row == 5){
        LoginViewController *loginVC = [[LoginViewController alloc] init];
        [tempAppDelegate.LeftSlideVC closeLeftView];//关闭左侧抽屉
        [tempAppDelegate.mainNavigationController pushViewController:loginVC animated:NO];
    } else if (indexPath.row == 6){
        SetViewController *setVC = [[SetViewController alloc] init];
        [tempAppDelegate.LeftSlideVC closeLeftView];//关闭左侧抽屉
        [tempAppDelegate.mainNavigationController pushViewController:setVC animated:NO];
        
    }
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 180;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableview.bounds.size.width, 180)];
    view.backgroundColor = [UIColor clearColor];
    return view;
}

//创建音乐栏
-(void)createMusicview{
    self.musicView = [[UIView alloc] initWithFrame:CGRectMake(0, 300, 375, 50)];
    self.musicView.backgroundColor = [UIColor redColor];
    [self.tableview addSubview:self.musicView];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
